﻿using JsonConversion;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.Mvc;
using RTracker.Models.Common;
using RTracker.Models.ErrorLog;
using System.Web.Security;

namespace RTracker.Areas.Recruitment.Models.VacancySalary
{
    public class MVacancySalary
    {
        /// static variable RowSize from config settings to get list of this row size.
        public static int nRowSize = Convert.ToInt32(ConfigurationManager.AppSettings["TotalRecordsInListVacancySalary"]);

        /// <summary>
        /// This method is used to create a VacancySalary in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details</returns>
        public CStatus CreateVacancySalary(CAuthenticationContext objCAuthenticationContext, ref CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_create_vacancy_salary_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@organization_id", SqlDbType.Int).Value = objCVacancySalary.OrganizationId;
                    cmd.Parameters.Add("@client_id", SqlDbType.Int).Value = objCVacancySalary.ClientId;
                    cmd.Parameters.Add("@vacancy_salary_name", SqlDbType.NVarChar).Value = objCVacancySalary.VacancySalaryName;
                    cmd.Parameters.Add("@vacancy_salary_desc", SqlDbType.NVarChar).Value = objCVacancySalary.VacancySalaryDesc;
                    cmd.Parameters.Add("@min_salary_annual", SqlDbType.Int).Value = objCVacancySalary.MinSalaryAnnual;
                    cmd.Parameters.Add("@max_salary_annual", SqlDbType.Int).Value = objCVacancySalary.MaxSalaryAnnual;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// This method is used to delete a VacancySalary in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus DeleteVacancySalary(CAuthenticationContext objCAuthenticationContext, ref CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_delete_vacancy_salary_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;
                    cmd.Parameters.Add("@vacancy_salary_ids", SqlDbType.NVarChar).Value = objCVacancySalary.VacancySalaryIds;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// This method is used to update the VacancySalary's detail in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus UpdateVacancySalary(CAuthenticationContext objCAuthenticationContext, ref CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_update_vacancy_salary_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@organization_id", SqlDbType.Int).Value = objCVacancySalary.OrganizationId;
                    cmd.Parameters.Add("@client_id", SqlDbType.Int).Value = objCVacancySalary.ClientId;
                    cmd.Parameters.Add("@vacancy_salary_name", SqlDbType.NVarChar).Value = objCVacancySalary.VacancySalaryName;
                    cmd.Parameters.Add("@vacancy_salary_desc", SqlDbType.NVarChar).Value = objCVacancySalary.VacancySalaryDesc;
                    cmd.Parameters.Add("@min_salary_annual", SqlDbType.Int).Value = objCVacancySalary.MinSalaryAnnual;
                    cmd.Parameters.Add("@max_salary_annual", SqlDbType.Int).Value = objCVacancySalary.MaxSalaryAnnual;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;
                      cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }

            return oCStatus;
        }

        /// <summary>
        /// This method is used to get the VacancySalary's detail in the database.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus GetVacancySalaryDetail(CAuthenticationContext objCAuthenticationContext, ref CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();
            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("r_get_vacancy_salary_detail_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;

                    SqlDataAdapter adp = new SqlDataAdapter(cmd);

                    DataTable dt = new DataTable();

                    int rowsAffected = adp.Fill(dt);

                    if (rowsAffected > 0)
                    {
                        objCVacancySalary = dt.ConvertToListFromDataTableVacancySalary()[0];
                    }

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.DetailSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }
            return oCStatus;
        }

        /// <summary>
        /// Sets the softlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus SetVacancySalarySoftLock(CAuthenticationContext objCAuthenticationContext, CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_set_vacancy_salary_soft_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// Sets the hardlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus SetVacancySalaryHardLock(CAuthenticationContext objCAuthenticationContext, CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_set_vacancy_salary_hard_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// Releases the softlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus ReleaseVacancySalarySoftLock(CAuthenticationContext objCAuthenticationContext, CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_release_vacancy_salary_soft_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        /// Releases the hardlock on the record whose Id is passed.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus ReleaseVacancySalaryHardLock(CAuthenticationContext objCAuthenticationContext, CVacancySalary objCVacancySalary)
        {
            CStatus oCStatus = new CStatus();

            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_release_vacancy_salary_hard_lock_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = objCAuthenticationContext.UserId;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;

                    cmd.ExecuteNonQuery();

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }


            return oCStatus;
        }

        /// <summary>
        ///  This function is used to get complete VacancySalary list
        /// </summary>
        /// <returns>List of type CVacancySalary</returns>
        public GVacancySalary GetVacancySalaryGridList(CVacancySalary objCVacancySalary, CAuthenticationContext objCAuthenticationContext)
        {
            GVacancySalary objGVacancySalary = new GVacancySalary();
            int nTotalRecords = 0;
            int nCurrentRowSize = nRowSize;

            if (objCVacancySalary.RowSize != 0)
            {
                nCurrentRowSize = objCVacancySalary.RowSize;
            }
            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    SqlCommand cmd = new SqlCommand("r_get_vacancy_salary_paging_list_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@vacancy_salary_id", SqlDbType.Int).Value = objCVacancySalary.VacancySalaryId;
                    cmd.Parameters.Add("@organization_id", SqlDbType.Int).Value = objCVacancySalary.OrganizationId;
                    cmd.Parameters.Add("@page_number", SqlDbType.Int).Value = objCVacancySalary.PageNumber;
                    cmd.Parameters.Add("@row_size", SqlDbType.Int).Value = nCurrentRowSize;
                    cmd.Parameters.Add("@sort_on", SqlDbType.VarChar).Value = objCVacancySalary.SortOn;
                    cmd.Parameters.Add("@sort_type", SqlDbType.VarChar).Value = objCVacancySalary.SortType;
                    cmd.Parameters.Add("@search", SqlDbType.VarChar).Value = objCVacancySalary.Search;
                    cmd.Parameters.Add("@searchon", SqlDbType.VarChar).Value = objCVacancySalary.SearchOn;
                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    cmd.Parameters["@error"].Direction = ParameterDirection.Output;
                    SqlDataAdapter adp = new SqlDataAdapter(cmd);

                    DataTable dt = new DataTable();

                    int rowsAffected = adp.Fill(dt);

                    objGVacancySalary.Paging = new CPaging();
                    if (rowsAffected > 0)
                    {
                        objGVacancySalary.lstVacancySalary = dt.ConvertToListFromDataTableVacancySalary();
                        objGVacancySalary.lstVacancySalary[0].PageNumber = int.Parse(cmd.Parameters["@idOut"].Value.ToString());
                        objGVacancySalary.Paging.PageNumber = objGVacancySalary.lstVacancySalary[0].PageNumber;
                    }
                    else
                    {
                        objGVacancySalary.lstVacancySalary = null;
                    }


                    nTotalRecords = int.Parse(cmd.Parameters["@error"].Value.ToString());

                    objGVacancySalary.Status = new CStatus();

                    if (nTotalRecords < 0)
                    {
                        objGVacancySalary.Status.Success = false;
                        objGVacancySalary.Status.StatusDetails = nTotalRecords.DbError();
                    }
                    else
                    {
                        objGVacancySalary.Paging.TotalRecordsCount = nTotalRecords;
                        objGVacancySalary.Paging.PageSize = nCurrentRowSize;

                        objGVacancySalary.Status.Success = true;
                        objGVacancySalary.Status.StatusDetails = "success";
                    }



                }
                catch (Exception ex)
                {
                    objGVacancySalary.Status = new CStatus();
                    objGVacancySalary.Status.Success = false;
                    objGVacancySalary.Status.StatusDetails = ex.Message;
                }
            }
            return objGVacancySalary;
        }

        /// /// <summary>
        ///  This function is used to get complete VacancySalary list working under a same organization.
        /// </summary>
        /// <param name="objCAuthenticationContext">This object contains information about VacancySalary's authentication context.</param>
        /// <param name="objCVacancySalary">This object contains details of the VacancySalary.</param>
        /// <param name="lstCVacancySalary">"out" the list of VacancySalarys</param>
        /// <returns>CStatus which is an object that contain transaction details.</returns>
        public CStatus GetVacancySalaryList(CAuthenticationContext objCAuthenticationContext, int organizationId, out List<CVacancySalary> lstCVacancySalary)
        {
            CStatus oCStatus = new CStatus();
            lstCVacancySalary = new List<CVacancySalary>();
            using (SqlConnection con = new SqlConnection(CCommonCollection.ConnectionString))
            {
                try
                {
                    con.Open();
                    SqlCommand cmd = new SqlCommand("r_get_vacancy_salary_list_procedure", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@organization_id", SqlDbType.Int).Value = organizationId;

                    cmd.Parameters.Add("@idOut", SqlDbType.Int).Value = null;
                    cmd.Parameters["@idOut"].Direction = ParameterDirection.Output;
                    //cmd.Parameters.Add("@error", SqlDbType.Int).Value = null;
                    //cmd.Parameters["@error"].Direction = ParameterDirection.Output;
                    SqlDataAdapter adp = new SqlDataAdapter(cmd);

                    DataTable dt = new DataTable();

                    int rowsAffected = adp.Fill(dt);

                    if (rowsAffected > 0)
                    {
                        lstCVacancySalary.AddRange(dt.ConvertToListFromDataTableVacancySalary());
                    }

                    if (Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()) > 0)
                    {
                        oCStatus.Success = true;
                        oCStatus.StatusDetails = CAppConstants.SessionSuccess;
                    }
                    else
                    {
                        oCStatus.Success = false;
                        oCStatus.StatusDetails = Convert.ToInt32(cmd.Parameters["@idOut"].Value.ToString()).DbError();
                        //oCStatus.StatusDetails = CAppErrorsConstants.SomethingWentWrong;
                    }
                }
                catch (Exception ex)
                {
                    oCStatus.Success = false;
                    oCStatus.StatusDetails = ex.Message;
                }
            }
            return oCStatus;
        }


    }
}